-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: ide-assists, some generate_\* indentations #19789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: ide-assists, some generate_\* indentations #19789
Conversation
crates/ide-assists/src/utils.rs
Outdated
@@ -250,6 +252,36 @@ pub fn add_trait_assoc_items_to_impl( | |||
first_item.unwrap() | |||
} | |||
|
|||
pub(crate) fn indent_string(mut s: &str, indent_level: IndentLevel) -> Cow<'_, str> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the wrong kind of API here, we already have indentation things that work on the AST. If those don't suffice this will have to wait until we have our own formatter to pretty print nodes with. Our assist output is currently best effort due to the lack of that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, many ide-assists directly generate strings. With this API, I can quickly fix nearly ten ide-assists implements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep this API and continue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this is that it makes us even more reliant on the text based editing, while we want to generate nodes proper and format them with a proper formatter. Until we have a formatter we only try to fix up indentation on a best effort basis.
(on a related note, all the assist PRs you have opened are text based which is also not ideal for the same reason)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(on a related note, all the assist PRs you have opened are text based which is also not ideal for the same reason)
Should I use ted
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this is that it makes us even more reliant on the text based editing, while we want to generate nodes proper and format them with a proper formatter. Until we have a formatter we only try to fix up indentation on a best effort basis.
Can this PR be merged? It doesn't seem to make things worse
b9e5dff
to
1d4eb9e
Compare
Fixed more indentation |
Fix files:
Example:
Old output:
Fixed output: